import { defineStore } from 'pinia';

export const userStore = defineStore('user', {
	state: () => {
		return {
			userInfo: uni.getStorageSync('userInfo') || {},
      		userInfoExt:uni.getStorageSync('userInfoExt') || {},
			token: uni.getStorageSync('token') || '',
		};
	},
	actions: {
		setUserInfo(info) {
			this.userInfo = info;
			uni.setStorage({
				key: 'userInfo',
				data: info,
			});
		},
		setUserInfoExt(info){
		  this.userInfoExt = info;
		  uni.setStorage({
			key:'userInfoExt',
			data:info
		  })
		},
		setToken(token) {
		  uni.setStorageSync('token', token);
		  this.token = token;
			/*uni.setStorage({
				key: 'token',
				data: token,
			});*/
		},
	},
});
